package com.lzk.工厂模式.工厂方法.order;

import com.lzk.工厂模式.工厂方法.pizza.Pizza;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * author: 刘中魁
 */
public abstract class OrderPizza {
//    构造器
    public OrderPizza() {
        Pizza pizza = null;
        String orderType;
        do {
            orderType = getType();
            pizza = createPizza(orderType);
            //输出披萨的制造过程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        }while (true);
    }

    //定义一个抽象方法 createPizza 让各个工厂子类自己实现
    abstract Pizza createPizza(String orderType);

    //写一个方法可以动态的获取客户希望订购的披萨种类
    private String getType(){
        try {
            BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza type:");
            String str = strin.readLine();
            return str;
        }catch (Exception e){
            e.printStackTrace();
            return "";
        }
    }

}
